<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring3-3.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
    <head th:include="template :: header" />
    <body>
        <div class="container">
            <div th:substituteby="template :: nav" />  
            <table id="table">
                <thead>
                    <tr>
                        <th>Report name</th>    
                        <th>Description</th>
                        <th>Action</th>
                    </tr>
                </thead>
                <tbody>
                    <tr align="center" th:each="rpt : ${reports}">
                        <td th:text="${rpt.reportName}" ></td>
                        <td th:text="${rpt.reportDescription}"></td>
                        <td>
                            <!--                            <a class='btn btn-info' href='#' target="_blank"
                                                           th:onclick="${'REPORT.run('''+rpt.reportId+''');'}">Run</a>
                                                        <span sec:authorize="hasRole('ROLE_EDIT')" >   
                                                            <a class="btn btn-info" href="#" 
                                                               th:onclick="${'REPORT.modify('''+rpt.reportId+''');'}">Modify</a>
                                                            <a  class="btn btn-info" href="#"
                                                                th:onclick="${'REPORT.edit('''+rpt.reportId+''');'}">Edit</a>
                                                            <a class="btn btn-info" href="#" 
                                                               th:onclick="${'REPORT.confirmDelete('''+rpt.reportId+''');'}">Delete</a>
                                                        </span>-->

                            <div class="btn-group btn-hover">
                                <button class="btn dropdown-toggle btn-primary" data-toggle="dropdown">Action <i class="icon-list icon-white"/></button>
                                <ul class="dropdown-menu">
                                    <li><a target="_blank" th:onclick="${'REPORT.run('''+rpt.reportId+''');'}"><i class="icon-fire"/> Run</a></li>
                                    <li><a th:onclick="${'REPORT.modify('''+rpt.reportId+''');'}"><i class="icon-asterisk"/> Modify</a></li>
                                    <li><a th:onclick="${'REPORT.edit('''+rpt.reportId+''');'}"><i class="icon-pencil"/> Edit</a></li>
                                    <li><a th:onclick="${'REPORT.confirmDelete('''+rpt.reportId+''');'}"><i class="icon-trash"/> Delete</a></li>
                                </ul>
                            </div>
                        </td>
                    </tr>

                </tbody>
            </table>
            <div th:include="template :: footer" id="footer"></div>
        </div>	
        <script th:inline="javascript">
            /*<![CDATA[*/
            jQuery(document).ready(function() {
                jQuery("#table").dataTable({"bJQueryUI": true});
                COMMON.activeMenu("report_nav");
            });

            REPORT = {
                confirmDelete: function(id)
                {
                    if (confirm("Are you sure to delete this?")) {
                        // your deletion code
                        var link = /*[[@{/admin/report/action/delete/}]]*/ "delete";
                        document.location.href = link + id;
                    }
                    return false;
                },
                modify: function(id)
                {
                    var link = /*[[@{/admin/report/action/modify/}]]*/ "modify";
                    document.location.href = link + id;

                },
                edit: function(id)
                {
                    var link = /*[[@{/admin/report/action/edit/}]]*/ "edit";
                    document.location.href = link + id;

                },
                run: function(id)
                {
                    var link = /*[[@{/admin/report/view/run/id/}]]*/ "run";
                    document.location.href = link + id;
                }
            };

            /*]]>*/
        </script>    
    </body>

</html>